package com.sdk.es.http.kafka;

import com.sdk.es.http.conts.Conts;
import com.sdk.es.sdk.constants.IndexConts;
import com.sdk.es.sdk.entity.base.Test1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @desc 注：修改和删除业务极少，默认关闭监听，需要再打开
 */
@Component
@Slf4j
public class Test1Consumer extends EsBaseConsumer<Test1> {
    /**
     * 初始化基础索引名称
     */
    @Override
    protected String initEsIndex() {
        return IndexConts.TEST1;
    }

    @Override
    @KafkaListener(topics = {
            Conts.TOPIC_PREFIX + IndexConts.TEST1 + Conts.TOPIC_SAVE_SUFFIX
            //,Conts.TOPIC_PREFIX +IndexConts.TEST1 + Conts.TOPIC_UPDATE_SUFFIX
            //,Conts.TOPIC_PREFIX + IndexConts.TEST1 + Conts.TOPIC_DELETE_SUFFIX
    },concurrency = "1")
    protected void listener(@Payload List<String> messageList, @Header(KafkaHeaders.RECEIVED_TOPIC) List<String> topicList) {
        super.listener(messageList, topicList);
    }
}
